'''
@Author: B.N
@Date: 2018-12-02 12:14:32
@LastEditors: B.N
@LastEditTime: 2018-12-02 12:46:13
@Description: 
'''
import stu_info_opera_class

#实例化一个操作数据库的对象
stu_db = stu_info_opera_class.stu_db_operat()

while True:
    # 输出初始界面
    print("="*20,"学生管理系统","="*20)
    print("{0:1} {1:13} {2:15}".format(" ","1. 查看学生信息","2. 添加学生信息"))
    print("{0:1} {1:13} {2:15}".format(" ","3. 删除学生信息","4. 退出系统"))
    print("="*40)
    key = input("请选择操作项目：")

    if key == "1":
        print("="*20,"学生信息浏览","="*20)
        stu_db.findAllInfo()
        input("按回车键继续：")
    elif key == "2":
        print("="*20,"学生信息添加","="*20)
        name = input("请输入学生姓名：")
        age = int(input("请输入学生年龄："))
        sex = input("请输入学生性别（'w' or 'm'）：")
        classid = input("请输入学生的班级号：")
        print(name,age,sex,classid)
        stu_db.insertInfo(name,age,sex,classid)
        stu_db.findAllInfo()
        input("按回车键继续：")
    elif key == "3":
        print("="*20,"学生信息删除","="*20)
        stu_db.findAllInfo()
        stu_id = int(input("请输入你要删除的信息id号："))
        stu_db.deleInfo(stu_id)
        stu_db.findAllInfo()
        input("按回车键继续：")
    elif key == "4":
        print("=" * 23, "退出程序", "=" * 23)
        break
    else:
        print("=" * 23, "输入无效", "=" * 23)

del stu_db